package com.binest.meetingInclusion.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.binest.meetingInclusion.domain.MeetingInclusionVo;
import com.binest.meetingInclusion.mapper.MeetingInclusionMapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.meetingInclusion.domain.MeetingInclusion;
import com.binest.meetingInclusion.service.IMeetingInclusionService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 会议收录Controller
 * 
 * @author wwd
 * @date 2024-01-03
 */
@RestController
@RequestMapping("/meetingInclusion")
public class MeetingInclusionController extends BaseController
{
    @Autowired
    private IMeetingInclusionService meetingInclusionService;

    /**
     * 查询会议收录列表
     */

    @GetMapping("/list")
    public TableDataInfo list(MeetingInclusion meetingInclusion) throws Exception {
        startPage();
        List<MeetingInclusion> list = meetingInclusionService.selectMeetingInclusionList(meetingInclusion);
        return getDataTable(list);
    }

    @GetMapping("/esList")
    public TableDataInfo esList(MeetingInclusionVo meetingInclusion) throws Exception {
        TableDataInfo list = meetingInclusionService.selectMeetingInclusionEsList(meetingInclusion);
        return list;
    }


    /**
     * 导出会议收录列表
     */
    @PreAuthorize("@ss.hasPermi('meetingInclusion:meetingInclusion:export')")
    @Log(title = "会议收录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MeetingInclusion meetingInclusion) throws Exception {
        List<MeetingInclusion> list = meetingInclusionService.selectMeetingInclusionList(meetingInclusion);
        ExcelUtil<MeetingInclusion> util = new ExcelUtil<MeetingInclusion>(MeetingInclusion.class);
        util.exportExcel(response, list, "会议收录数据");
    }

    /**
     * 获取会议收录详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id){
        return success(meetingInclusionService.selectMeetingInclusionById(id));
    }

    /**
     * 获取es会议收录详细信息
     */
    @GetMapping(value = "/getEsInfo")
    public AjaxResult getEsInfo(String id) throws Exception {
        return success(meetingInclusionService.selectEsMeetingInclusionById(id));
    }

    /**
     * 新增会议收录
     */
//    @PreAuthorize("@ss.hasPermi('meetingInclusion:meetingInclusion:add')")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody MeetingInclusion meetingInclusion)
    {
        return success(meetingInclusionService.insertMeetingInclusion(meetingInclusion));
    }

    /**
     * 修改会议收录
     */
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody MeetingInclusion meetingInclusion)
    {
        return toAjax(meetingInclusionService.updateMeetingInclusion(meetingInclusion));
    }

    /**
     * 删除会议收录
     */
    @Log(title = "会议收录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(meetingInclusionService.deleteMeetingInclusionByIds(ids));
    }
}
